package com.lvtongka.app.dialog

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.lvtongka.app.R

class LoadingDialog(context: Context, private val message: String = "加载中...") : AlertDialog(context, R.style.MyDialog) {
    private var dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null)
    private var mLoadingText: TextView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setCancelable(false)
        setContentView(dialogView)
    }

    init {
        mLoadingText = dialogView.findViewById(R.id.tips_loading_msg)
        setMessage(message)
    }

    fun setMessage(message: String) {
        mLoadingText?.let {
            it.text = message
            it.visibility = View.VISIBLE
        }
    }
}